import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, CommonButton } from '../Common/options'

export const ReceiveUser = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()['getMasterDataEmpList'],
        options: [
            // <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            <CommonButton
                key="A01"
                type="primary"
                OptionsEvent={OptionsEvent}
                title="一键添加"
                data={{ type: 'OneClickSettingsA01', data: 0, width: 600 }}
            />,
            <CommonButton
                key="A02"
                type="primary"
                OptionsEvent={OptionsEvent}
                title="一键更新"
                data={{ type: 'OneClickSettingsA01', data: 1, width: 600 }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'status',
                title: '同步状态 ',
                valueType: 'select',
                valueEnum: {
                    未添加: { text: '未添加', status: 'error' },
                    已添加: { text: '已添加', status: 'success' },
                    需更新: { text: '需更新', status: 'processing' },
                },
                width: 80,
            },
            {
                dataIndex: 'pkOrgName',
                title: '组织机构',
                valueType: 'input',
                width: 320,
            },
            {
                dataIndex: 'pkDeptName',
                title: '部门名称',
                valueType: 'input',
                width: 160,
            },
            {
                dataIndex: 'name',
                title: '姓名',
                valueType: 'input',
                width: 80,
            },
            {
                dataIndex: 'sexName',
                title: '性别',
                valueType: 'input',
                width: 80,
            },
            {
                dataIndex: 'mobile',
                title: '联系方式',
                valueType: 'input',
                width: 120,
            },
            {
                dataIndex: 'idCard',
                title: '身份证',
                valueType: 'input',
                width: 160,
            },
            {
                dataIndex: 'empStatusName',
                title: '人员状态',
                valueType: 'input',
                width: 80,
            },
            {
                dataIndex: 'code',
                title: '人员编号',
                valueType: 'input',
                width: 120,
            },
            {
                dataIndex: 'beginDate',
                title: '进场时间',
                valueType: 'input',
                width: 160,
                hideInSearch: true,
            },
            {
                dataIndex: 'endDate',
                title: '退场时间',
                valueType: 'input',
                width: 160,
                hideInSearch: true,
            },
            {
                dataIndex: 'createTime',
                title: '创建时间',
                valueType: 'input',
                width: 160,
                hideInSearch: true,
            },
            {
                dataIndex: 'modifyTime',
                title: '修改时间 ',
                valueType: 'input',
                width: 160,
                hideInSearch: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 80,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { personUuid } = record
                    return [
                        personUuid ? (
                            <CommonButton
                                key="modify"
                                OptionsEvent={OptionsEvent}
                                title="更新"
                                data={{
                                    type: 'ModifyNewPerson',
                                    // smallTitle: labReportTemplateTableName + ' 二维码',
                                    record,
                                    width: 800,
                                }}
                            />
                        ) : (
                            <CommonButton
                                key="added"
                                OptionsEvent={OptionsEvent}
                                title="新增"
                                data={{
                                    type: 'AddedNewPerson',
                                    record,
                                    width: 800,
                                }}
                            />
                        ),
                        // getPerson: `${API}/persons`,
                        // putPerson: `${API}/persons/${path[0]}`,
                    ]
                },
            },
        ],
    }

    return data
}
